﻿@{
    ViewBag.Title = "JQueryAjaxForm";
}

<h2>JQueryAjaxForm</h2>

<form id="ajax">
    
    <input type="text" name="vorname"/>
    <input type="text" name="nachname"/>

    <input type="submit" name="Submit" id="absenden"/>
    <a href="#" id="absenden2">absenden mit Link </a>

</form>

<div id="fullName"></div>

<script>

    (function ($) {

        $('#absenden').on('click', function (event) {
            event.preventDefault();

            $.post('http://localhost:52328/Home/GetName', $('#ajax').serialize(), function(result) {
                if (result) {
                    $('#fullName').text(result);
                }
            });

        });

        $('#absenden2').on('click', function (event) {
            event.preventDefault();

            $.post('http://localhost:52328/Home/GetName', $('#ajax').serialize(), function (result) {
                if (result) {
                    $('#fullName').text(result);
                }
            });

        });


    })(window.jQuery);


</script>